﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            color: #33CC33;
            font-weight: bold;
        }
    </style>
</head>
<body>

    <h3>
        Introducing Cosmos</h3>
    <p>
        Cosmos (<span class="style1">C#</span> <span class="style1">O</span>pen 
        <span class="style1">S</span>ource <span class="style1">M</span>anaged 
        <span class="style1">O</span>perating <span class="style1">S</span>ystem) 
        is an operating system development kit which uses Visual Studio as its 
        development environment. Despite C# in 
        the name any .NET based language can be used including VB.NET, Fortran, Delphi 
        Prism, IronPython, F# and more. Cosmos itself and the kernel routines are 
        primarily written in C#, and thus the Cosmos name. Besides that, NOSMOS (.NET 
        Open Source Managed Operating System) sounds stupid.</p>
    <p>
        Cosmos is not an operating system in the traditional sense, but instead it is 
        an &quot;Operating System Kit&quot;, or as I like to say &quot;Operating System Legos&quot;. 
        Cosmos lets you create operating systems just as Visual Studio and C# normally 
        let you create applications. Most users can write and 
        boot their own operating system in just a few minutes, all using Visual Studio. 
        Milestone 5 includes new features such as an integrated project type in Visual 
        Studio, and an integrated debugger. You can debug your operating system directly 
        from Visual Studio using breakpoints.</p>
    <p>
        Cosmos is available in two distributions, the developer kit (dev kit), and the 
        user kit. The dev kit is designed for users who want to work on Cosmos itself. 
        The user kit is designed for those who are interested in building their own 
        operating system and doing some Cosmos work. The dev kit might be thought of as 
        the Cosmos SDK. Most users should start off with the user kit as it is not so 
        overwhelming like the dev kit. This article focuses on the user kit.</p>
    <h3>
        Writing your first Operating System</h3>
    <p>
        Create a new project as you would any C# project, but select Cosmos as the project 
        type.</p>
    <p>
        <img alt="" src="CosmosMS5/SNAG-0000.png" style="width: 630px; height: 516px" /></p>
    <p>
        A starter project will be created. It looks very much like a standard C# console 
        application.</p>
    <p>
        <img src="CosmosMS5/SNAG-0001.png" style="width: 232px; height: 143px" /></p>
    <p>
        Program.cs contains the boot and execution code. Instead of seeing a Windows 
        console window, you will see the following:</p>
    <p>
        <img src="CosmosMS5/SNAG-0003.png" style="width: 738px; height: 464px" /></p>
    <p>
        This is your operating system running in VMWare Player! Cosmos can of course 
        also be booted in VMWare Workstation, Hyper-V, Virtual PC, or on real hardware. 
        But by default Cosmos uses VMWare Player because it is both free, and reliable. 
        Cosmos can even debug in Visual Studio, even when running on another machine.</p>
    <h3>
        Integrated
        Debugging</h3>
    <p>
        Debugging is a major issue with operating system development. The Cosmos team 
        was not content enough to simply conquer building and deployment, we want to 
        make developing operating system as easy as developing Windows applications. 
        Debugging a Cosmos based operating system should feel very familiar to you. Lets 
        modify our project a little bit to show the effect, and set a breakpoint.</p>
    <p>
        <img src="CosmosMS5/SNAG-0005.png" style="width: 870px; height: 493px" /></p>
    <p>
        Now run the project again.</p>
    <p>
        <img src="CosmosMS5/SNAG-0007.png" style="width: 1177px; height: 513px" /></p>
    <p>
        Note that the execution stopped at &quot;One&quot;? That is becuase in Visual Studio our 
        project has stopped on a breakpoint. Simply press F5 to continue just as you 
        would in a normal application!</p>
    <p>
        In addition to breakpoints Cosmos also supports step into (F11) as well. Trace 
        over (F10) is not supported yet.</p>
    <h3>
        Debugger Communication</h3>
    <p>
        The debugger uses the serial port to communicate. Because of this, debugging 
        only works wtih virtualization environments that support serial ports such as 
        VMWare. QEMU supports serial ports as well, but its serial port implementation 
        is seriously broken on Windows and makes debugging impossible using QEMU. To debug on real hardware, you must use a 
        physical serial cable. In the future Cosmos will also support debugging over 
        Ethernet.</p>
    <h3>
        Extra Debugging</h3>
    <p>
        Cosmos supports some explicit methods that can be used to communicate with the 
        debugger and use additional functionality. It is accessed using the Debugger 
        class in the Cosmos.Debug namespace in the Cosmos.Kernel assembly. This assembly 
        is used by all Cosmos projects.</p>
    <h3>
        Code Based Breakpoints</h3>
    <pre>Debugger.Break();</pre>
    <p>
        Break can be used to issue a code based break. Visual Studio will break on the 
        line after this statement.     </p>
    <p>
        <img src="CosmosMS5/SNAG-0006.png" style="width: 509px; height: 174px" /></p>
    <p>
        Since Cosmos does not support conditional breakpoints in the IDE yet, code base 
        breaks are very useful for implementing such. For example:</p>
    <pre>if (x == 5) {
    Debugger.Break();
}</pre>
    <p>
        Alternatively you can call the .NET class libary break:</p>
    <pre>System.Diagnostics.Debugger.Break();</pre>
    <p>
        Both functions will produce the same result.</p>
    <h3>
        Debug Output</h3>
    <p>
        Debug strings can be output to the debug window of the host. Because Cosmos does 
        not support watches yet, this functionality can be very useful for watching 
        variable values and for performing tracing without breakpoints.</p>
    <pre>Debugger.Send(&quot;Hello from Cosmos!&quot;);</pre>
    <p>
        When this line is executed, it will send a message over the debugging channel 
        and it will appear in the Visual Studio output window.</p>
    <p>
        <img alt="" src="CosmosMS5/SNAG-0008.png" style="width: 454px; height: 118px" /></p>
    <h3>
        What&#39;s the catch?</h3>
    <p>
        There really is no catch. Everything I&#39;ve shown here is functioning as seen. 
        No mockups were used. However we still have a lot of work to go. Items of interest that 
        are on our current task list include interfaces (necessary for foreach), file 
        systems (partial support exists), threads, networking, and graphics. We have 
        prototypes and experimentation for each, but none have been rolled into the 
        mainline Cosmos development as of yet.</p>
    <h3>
        What was that Syslinux thing I saw on boot?</h3>
    <p>
        Cosmos does not run on Linux. A boot loader called Syslinux is used to boot 
        Cosmos. After booting, Syslinux is not used. Syslinux is a bootloader and is not 
        a Linux distro.</p>
    <h3>
        Obtaining Cosmos</h3>
    <ul>
        <li>Cosmos Website - <a href="http://www.GoCosmos.org">http://www.GoCosmos.org</a></li>
        <li>Source Code - Both dev kit and user kit - <a href="http://Cosmos.CodePlex.com">
            http://Cosmos.CodePlex.com</a></li>
    </ul>
        
</body>
</html>
